using HZY.Framework.Aop.Attributes;
using HZY.Framework.DependencyInjection;
using HZY.Framework.DependencyInjection.Attributes;
using HZY.Framework.DependencyInjection.Test;
using Scrutor;
using System.Reflection;
using HZY.Framework.Aop;

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.

builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();

// builder.Services.AddDependencyInjection(new List<Assembly> { typeof(User).Assembly });

builder.Services.AddDependencyInjection((opt) =>
{
    opt.Assemblies = new List<Assembly> { typeof(User).Assembly };
    opt.RegistrationStrategy = RegistrationStrategy.Replace();
});

builder.Services.AddDependencyInjectionByComponent([typeof(User).Assembly]);

builder.Services.AddTransient<IReposiroty<User>, Reposiroty<User>>();
builder.Services.AddTransient<UserService>();
builder.Services.AddTransient<TestEntity>();

builder.Host.ReplaceServiceProvider();

builder.AddAop();

Environment.SetEnvironmentVariable("TestNameEnv", "0000");
var a = new TestEntity1();
var aDefault = a.Default;

var app = builder.Build();

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
    app.UseSwagger();
    app.UseSwaggerUI();
}

app.UseAop();

app.UseHttpsRedirection();

app.UseAuthorization();

app.MapControllers();

app.Run();